import { defineStore } from 'pinia'
import { ref } from 'vue'

export const usePageStateStore = defineStore('pageState', () => {
  // 存储上一页（Home）的状态
  const homeState = ref({
    inputValue: '', // 输入框内容
    scrollTop: 0 // 滚动位置
  })

  // 保存Home页状态
  function saveHomeState(state) {
    homeState.value = { ...state }
  }

  // 清空Home页状态
  function clearHomeState() {
    homeState.value = { inputValue: '', scrollTop: 0 }
  }

  return { homeState, saveHomeState, clearHomeState }
})